<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import "./assets/css/base.css";
import "./assets/css/index.css";
import "./assets/css/index_before.css";

export default {
  name: "App",

  data() {
    return {
      name: "appp",
      title: "",
      // procedureConfig: {},
      loginInfo: {
        userType: 0,
      },
      // cookieRenewal: false
    };
  },
  created: function () {
    var that = this;
    this.common._setVue(this);

    // this.api.consoleUrl =this.api.consoleUrl +"/token";
    var loginInfo = this.$cookies.get("loginInfo");
    if (loginInfo != undefined) {
      this.loginInfo = loginInfo;
    }

    this.common.getHttpHeaders = function () {
      var token = that.$cookies.get("token");
      // that.cookieRenewal = (token != undefined);
      token = token == undefined ? "" : token;
      var h = {
        token: token,
      };
      return h;
    };

    // this.common.post(this.api.getProcedureConfig, {}, function(res) {
    //     var res = JSON.parse(res.resultMap);
    //     that.procedureConfig = res;
    //     that.title = res.title;
    // });

    this.common.xujiqi = that.getNewToken;
  },
  mounted: function () {},
  methods: {
    getNewToken: function (url, data) {
      if (
        url == this.api.getNewToken ||
        url == this.api.verifyCode ||
        url == this.api.login ||
        url == this.api.getVerifyCodeLogin ||
        url == this.api.fileManagerUpload ||
        url == this.api.getTicketByIdentityCode ||
        url == this.api.uploadFile ||
        url == this.api.getUploadFileCheckPass
      ) {
        return;
      }
      var that = this;
      this.common.post(
        this.api.getNewToken,
        {},
        function (res) {
          if (res.resultMap == "false") {
            that.$message.warning("您的账号已在其它电脑登录！！！");
            setTimeout(function () {
              that.common.toPage("/login", true);
            }, 2000);
            return;
          }
          if (
            res.resultMap == that.$cookies.get("token") ||
            String.isEmptyOrNUll(res.resultMap)
          ) {
            return;
          }
          that.$cookies.set("token", res.resultMap, that.api.config.tokenTime);
        },
        function (err) {
          that.$message.error(err.resultMsg);
          that.$cookies.set("token", undefined);
          that.common.toPage("/login");
        }
      );
    },
  },
};
</script>

<style>
</style>
